package com.cai.servlet.item;

import com.cai.dao.GoodsDao;
import com.cai.dao.impl.GoodsDaoImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/**
 * @author RuoLi
 */
@WebServlet(name = "ServletItemDelete", value = "/itemDelete")
public class ServletItemDelete extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("item_id");
        GoodsDao goodsDao = new GoodsDaoImpl();
        int code = goodsDao.deleteGoods(Integer.parseInt(id));
        if (code!=0){
            //删除成功
            response.getWriter().println(1);
        }else {
            response.getWriter().println(0);
        }
    }
}
